package gatperdut.chato.core.interpreter.actions;

import gatperdut.chato.constants.CSConstantsCommandResult.CommandExecutionResult;
import gatperdut.chato.constants.CSConstantsString;
import gatperdut.chato.core.characters.BaseController;
import gatperdut.chato.core.interpreter.actions.generic.Action;
import gatperdut.chato.core.interpreter.grammar.comminfo.InvInfo;

public class InvAction extends Action {

    public InvAction( InvInfo info, BaseController entityController ) {
        super( info, entityController );
    }

    @Override
    public CommandExecutionResult perform() {
        checkForRunningCraft();

        if ( getEntityController().getInventoryController().isEmpty() ) {
            getEntityController().tx( "You are naked." );
            return CommandExecutionResult.OK;
        }

        StringBuilder sb = new StringBuilder( "You are carrying:" + CSConstantsString.NEWLINE );
        sb.append( getEntityController().getInventoryController().listContentsShortDescription( true ) );

        getEntityController().tx( sb.toString() );

        return CommandExecutionResult.OK;
    }

    @Override
    public InvInfo getInfo() {
        return (InvInfo) super.getInfo();
    }

    @Override
    public boolean interruptsCrafting() {
        return false;
    }

}
